package com.zhima.controller.feign;

import com.zhima.service.impl.PhoneCheckCodeServiceImpl;
import com.zhima.util.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/feign/phone")
public class PhoneFeignController {
    @Autowired
    private PhoneCheckCodeServiceImpl phoneCheckCodeService;

    /**
     * 验证手机验证码
     *
     * @param phone
     * @param submitCheckCode
     * @return
     */
    @GetMapping("/verify/{submitCheckCode}/{phone}")
    public String verifyPhoneCheckCode(@PathVariable("phone") String phone, @PathVariable("submitCheckCode") String submitCheckCode) {
        return phoneCheckCodeService.verifyCheckCode(phone, submitCheckCode);
    }

    /**
     * 验证手机验证码
     *
     * @param submitCheckCode
     * @return
     */
    @GetMapping("/verify/{submitCheckCode}")
    public String verifyPhoneCheckCode(@PathVariable("submitCheckCode") String submitCheckCode) {
        return phoneCheckCodeService.verifyCheckCode(UserHolder.get().getPhone(), submitCheckCode);
    }
}
